import os
import re
import sys

specs_dir=sys.argv[1]
print(specs_dir)
requires_dict = {}
for root, dirs, files in os.walk(specs_dir):
    print(len(files))
    print("+++++")
    for f in files:
        name = f.split(".spec")[0]
        with open(os.path.join(root, f)) as f:
            text_str=f.read()
            str_find = '.*Requires: (.*)'
            tmp = re.findall(str_find, text_str)
            requires_dict[name] = []
            for t in tmp:
               if "," in t:
                   requires_dict[name] = requires_dict[name] + list(set(t.split(",")) - set(['']))
               else:
                   requires_dict[name] = requires_dict[name] + list(set(t.split(" ")) - set(['']))
                   
        print(requires_dict)
        break
        
